package com.shuangti.business.controller;

import com.shuangti.business.service.BusinessService;
import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/shopping")
public class PurchaseRestController {

    @Autowired
    BusinessService businessService;


    @GlobalTransactional
    @GetMapping("/purchase")
    public String purchase(@RequestParam("user_id") Long user_id,
                           @RequestParam("product_id") Long product_id,
                           @RequestParam("count") int orderCount,
                           @RequestParam("address") String address){
        businessService.purchase(user_id,product_id,orderCount,address);
        return "business purchase success";
    }
}
